
import Vue from 'vue';
import VueRouter from 'vue-router';


import Home from './view/home.vue';
import Join from './view/join.vue';
import appJoin from './view/appJoin.vue';
import Callback from './view/callback.vue';
import ErrorPage from './view/404.vue';

const routes = [
  {
    path: '/',
    title: '首页',
    name: 'home',
    component: r => require.ensure([], () => r(Home), 'home'),
  },
  {
    path: '/connect/join',
    title: '参与我们',
    name: 'join',
    component: r => require.ensure([], () => r(Join), 'join'),
  },
  {
    path: '/connect/appJoin',
    title: '参与我们',
    name: 'appJoin',
    component: r => require.ensure([], () => r(appJoin), 'appJoin'),
  },
  {
    path: '/callback/wechat',
    title: '微信回调',
    name: 'callback',
    component: r => require.ensure([], () => r(Callback), 'callback'),
  },
  {
    path: '/connect/error',
    title: '链接无效',
    name: 'error',
    component: r => require.ensure([], () => r(ErrorPage), 'error'),
  },
];
Vue.use(VueRouter);

const router = new VueRouter({
  routes,
});

router.beforeEach((to, from, next) => {
  console.log('router changed. ', to.name, to.path);
  next();
});
export default router;
